﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NMF.Languages
{
    public class FloatType : DataType
    {
        public FloatType() : base("Float")
        {
            AllowInfinity = true;
            AllowNaN = true;
            AllowNegatives = true;
            IsDoublePrecision = true;
            PositiveMinimum = double.Epsilon;
            Maximum = double.MaxValue;
        }

        public bool AllowNegatives { get; set; }
        public bool AllowNaN { get; set; }
        public bool AllowInfinity { get; set; }
        public double PositiveMinimum { get; set; }
        public double Maximum { get; set; }

        public bool IsDoublePrecision { get; set; }

        public override void Visit(ITypeVisitor visitor)
        {
            visitor.VisitFloat(this);
        }

        public override T Visit<T>(ITypeVisitor<T> visitor)
        {
            return visitor.VisitFloat(this);
        }

        public override T Visit<S, T>(ITypeVisitor<S, T> visitor, S parameter)
        {
            return visitor.VisitFloat(this, parameter);
        }

        public override System.Type SystemType
        {
            get { return IsDoublePrecision ? typeof(double) : typeof(float); }
        }
    }
}
